package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.SendMapper;
import com.lune.job.pojo.Send;
import com.lune.job.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class SendServiceImpl extends ServiceImpl<SendMapper, Send> implements ISendService {

    @Autowired
    private SendMapper sendMapper;
    @Autowired
    private IResumeService resumeService;

    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IPostService postService;

    @Autowired
    private IStudentService studentService;
    @Override
    public boolean updateStatus(Send send) {
        return sendMapper.updateStatus(send);
    }

    @Override
    public IPage<Send> queryPage(Integer currentPage, Integer size, Send send) {
        Page<Send> page = new Page<>(currentPage, size);
        IPage<Send> postIPage = sendMapper.queryPage(page,send);
        return postIPage;
    }

    @Override
    public List<Send> queryByCon(Send send) {
        List<Send> sends = sendMapper.queryByCon(send);
        sends.forEach(item->{
            item.setCompany(companyService.getById(item.getCompany_id()));
            item.setResume(resumeService.getById(item.getResume_id()));
            item.setStudent(studentService.getById(item.getStudent_id()));
            item.setPost(postService.getById(item.getPost_id()));
        });
        return sends;
    }


}
